import java.util.Scanner;

public class myCode {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputString = scanner.nextLine();
        String[] intarr = inputString.split(",");

        int length = solution(intarr);
        System.out.println(length);
    }

    private static int solution(String[] intarr) {
        if (intarr.length <= 1) {
            return -1;
        }

        int count = 0;
        for (int i = 0; i < intarr.length - 1; i++) {
            String numberOne = intarr[i].trim();
            for (int j = i + 1; j < intarr.length; j++) {
                String numberTwo = intarr[j].trim();
                if (isPalindrome(numberOne + numberTwo) || isPalindrome(numberTwo + numberOne)) {
                    count++;
                }
            }
        }
        return count > 0 ? count : -1;
    }

    private static boolean isPalindrome(String string) {
        if (string.length() <= 1) {
            return true;
        }
        for (int i = 0; i < string.length() / 2; i++) {
            if (string.charAt(i) != string.charAt(string.length() - 1 - i)) {
                return false;
            }
        }
        return true;
    }

}
